//package com.qf.index;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.io.IORuntimeException;
//import cn.hutool.core.util.NumberUtil;
//import cn.hutool.db.Db;
//import cn.hutool.db.Entity;
//
//import java.io.File;
//import java.io.IOException;
//import java.nio.file.Files;
//import java.sql.SQLException;
//import java.sql.SQLOutput;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.Date;
//import java.util.List;
//
//public class PDF {
//
//    public static void main(String[] args) throws SQLException {
//
//        System.out.println("asd");
//
/// /        List<File> files = FileUtil.loopFiles("G:\\pdf\\");
/// /        int num = 0;
/// /        int sum = 2;
/// /        String txt = "I:\\2025_01_22_pdf\\dir.txt";
/// /        for (File file : files) {
/// /            String filePath = file.getAbsolutePath();
/// /            String f = filePath.toLowerCase().trim();
/// /            if (f.endsWith(".pdf") ) {
/// /                String fileId = Utils.getFileId(filePath);
/// /                if (!fileId.isEmpty()) {
/// /                    num++;
/// /                    if (num == 1000) {
/// /                        num = 0;
/// /                        sum++;
/// /                        System.out.println("拷贝1000个了：" + sum);
/// /                    }
/// /                    copyFile(filePath, "I:\\2025_01_22_pdf\\" + sum, "");
/// /                    FileUtil.appendUtf8String(filePath + System.lineSeparator(), txt);
/// /                }
/// /            }
/// /        }
/// /        String uploadTable = "dir.upload_pdf_server_table_0331";
/// /        readTable(uploadTable, "id", "fullpath");
//
//
/// /        String tempPath = "E:\\gDiskPdf\\第73批--515篇12.28\\第73批--515篇12.28\\Zombies and Conundrums Source Sci Am 2021 324 2 4[PMIDT39020709].PDF.pdf";
/// ///        FileUtil.del(tempPath);
/// /
/// /        if (FileUtil.exist(tempPath)) {
/// /            System.out.println("存在这个文件");
/// /            FileUtil.del(tempPath);
/// /        } else {
/// /            System.out.println("不存在这个文件");
/// /            FileUtil.del(tempPath);
/// /        }
/// /        delFile();
//
//    }
//
////    public static void delFile() {
////        List<String> list = FileUtil.readLines("I:\\2025_01_21_pdf\\dir_UTF8.txt", "utf-8");
////        for (String tempPath : list) {
////            try {
////                FileUtil.del(tempPath);
////            } catch (IORuntimeException e) {
//////                throw new RuntimeException(e);
////            }
////            if (FileUtil.exist(tempPath)) {
////                System.out.println("没有删除成功，仍存在这个文件！" + tempPath);
////                try {
////                    FileUtil.del(tempPath);
////                } finally {
////
////                }
////            }
////        }
////    }
//
////    public static void readTable(String uploadTable, String autoId, String field) throws SQLException {
////        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
////        int onePageNum = 1000;
////        List<Entity> tableNum = Db.use().query("select count(1) as count from " + uploadTable);
////        int num = 0;
////        int sum = 0;
////        String txt = "F:\\toServer\\dir.txt";
////        if (tableNum.get(0).getInt("count") > 0) {
////            int tableMax = Db.use().queryNumber("select max(" + autoId + ") from " + uploadTable).intValue();
////            Collection<Integer> tableList = new ArrayList<>();
////            NumberUtil.appendRange(0, tableMax + onePageNum, onePageNum, tableList);
////            for (Integer startId : tableList) {
////                List<Entity> tableData = Db.use().query("select `" + autoId + "`,`" + field + "` from " + uploadTable + " where " + autoId + " between " + startId + " and " + (startId + onePageNum - 1));
////                System.out.println("\033[31;1m" + format.format(new Date()) + " 读表现在开始：" + startId + " 表名：" + uploadTable + Utils.printMemoryStr() + "\033[0m");
////                for (Entity entry : tableData) {
////                    String filePath = entry.getStr("fullpath");
////                    String f = filePath.toLowerCase().trim();
////                    if (f.endsWith(".pdf")) {
////                        String fileId = Utils.getFileId(filePath);
////                        if (!fileId.isEmpty()) {
////                            num++;
////                            if (num == 1000) {
////                                num = 0;
////                                sum++;
////                                System.out.println("拷贝1000个了：" + sum);
////                            }
////                            copyFile(filePath, "F:\\toServer\\" + sum, "");
////                            FileUtil.appendUtf8String(filePath + System.lineSeparator(), txt);
////                        }
////                    }
////                }
////            }
////        }
////    }
//
//    // 复制文件。比如来源文件source:E:\\dir_47p_0512.txt  指定目录newPath:E:\\51P，若newFileName新文件名为空，仍是原来的文件名字，若有新文件名，则保存为新的文件名。
//    // copyFile("G:\\lh_2023_12_21\\郜冰洁\\6月\\6.11-6.16\\已上传\\Sciatica [PMIDM29821100].pdf","H:\\S201791LH\\2023-10-1\\","Sciatica Source Hospital Lond 1886 1891 Feb 14 9 229 303[PMIDT29821100].PDF");
//    // copy("G:\\lh_2023_12_21\\以前同事\\seven\\二月\\2.18\\已上传\\1.pdf", "F:\\lh_2023_12_21\\以前同事\\seven\\二月\\2.18\\已上传",""); 这样可以在指定的位置新建相对应的文件目录，但仍是原来的文件名字
//    // String newPath = "E:\\gDiskPdf\\" + source.substring("G:\\".length(), source.lastIndexOf("\\"));
////    public static void copyFile(String source, String newPath, String newFileName) {
////        File oldFile = new File(source);
////        String fileName = source.substring(source.lastIndexOf("\\") + 1);
////        // 如果指定的目录不存在，则先给予创建
////        File directory = new File(newPath);
////        if (!directory.exists()) {
////            directory.mkdirs();
////        }
////        // 如果新的目录最后是以"\\"结尾，就不需要再添加了，如果不是，则添加上目录与文件之间的"\\"分隔符。
////        String split = newPath.endsWith("\\") ? "" : "\\";
////        File newFile = new File(newPath + split + (newFileName.length() > 1 ? newFileName : fileName));
////        // 如果目录中已存在该文件，则将已存在的给予删除，再执行复制。
////        if (newFile.exists()) {
////            newFile.delete();
////        }
////        try {
////            Files.copy(oldFile.toPath(), newFile.toPath());
////        } catch (IOException e) {
////            e.printStackTrace();
////        }
////    }
//
//
//}
